public int SetRowColumn(
int row,
int column,
byte[] buffer,
int bufferIndex,
int bufferCount
)
- (NSInteger)setRowColumn:(NSInteger)row
column:(NSInteger)column
buffer:(const unsigned char *)buffer
bufferCount:(unsigned long)count
error:(NSError **)error
public int setRowColumn(
int row,
int column,
byte[] buffer,
int bufferIndex,
long bufferCount
)
public:
int SetRowColumn(
int row,
int column,
array<byte>^ buffer,
int bufferIndex,
int bufferCount
)
def SetRowColumn(self,row,column,buffer,bufferIndex,bufferCount):
row
The number of the row to update. The first row is 0, and the last row is 1 less than the image height.
column
The column offset within the row to update. The first column offset is 0, and the last column offset is 1 less than the image width.
buffer
Buffer containing the image data. The buffer should contain uncompressed data regardless of whether the image is compressed or not.
bufferIndex
0-based index into the output buffer. This is the start location of input data.
bufferCount
The number of bytes to update. Consider the bits per pixel, and avoid specifying a number that goes past the end of the row.
For a 1-bit image, each byte represents 8 pixels. For a 4-bit image, each byte represents 2 pixels. For an 8-bit image, each byte represents 1 pixel. For a 16-bit image, every 2 bytes represents one pixel. For 24-bit images, every three bytes represents one pixel. For a 32-bit image, every four bytes represents one pixel. For a 48-bit image, every six bytes represents one pixel. For a 64-bit image, every eight bytes represents one pixel.
The number of bytes put.
By using this low-level method to update any part of a row, you can write a procedure that updates a single pixel or a rectangular area within the image.
This method accepts an offset parameter ( column) in pixels and a length ( bufferCount) in bytes. Therefore, you must consider the bits per pixel of the image when specifying these parameters. The following table describes the rules:
Bits Per Pixel | Column Offset (in Pixels) | Bytes to Get |
---|---|---|
1 | Must be a multiple of 8 (such as 0, 8, or 16). | Can be any number up to the end of the row. Consider that there are 8 pixels per byte. |
4 | Must be an even number (such as 0, 2, or 4). | Can be any number up to the end of the row. Consider that there are 2 pixels per byte. |
8 | Can be any column within the image. | Can be any number up to the end of the row. Consider that there is 1 pixel per byte. |
16 | Can be any column within the image. | Must be a multiple of 2 (such as 2, 4, or 6), because there are 2 bytes per pixel. |
24 | Can be any column within the image. | Must be a multiple of 3 (such as 3, 6, or 9), because there are 3 bytes per pixel. |
32 | Can be any column within the image. | Must be a multiple of 4 (such as 4, 8, or 12), because there are 4 bytes per pixel. |
The image memory must be locked when you use this method. Normally, you can call Access to lock the memory before starting an operation that uses this method. Then call Release when the operation is finished.
Color order is determined by the Order property of the RasterImage object. This value can be RasterByteOrder.Rgb, RasterByteOrder.Bgr, or RasterByteOrder.Romm.
Note: To calculate the correct size for a single row of image data:
(((Width * BitsPerPixel) + 31) >> 3)) & ~3
(((Width * BitsPerPixel) + 7) / 8)
RasterByteOrder.Gray is only valid for 12 and 16-bit grayscale images. Support for 12 and 16-bit grayscale images is only available in the Document/Medical Imaging editions.
For more information, refer to Introduction to Image Processing With LEADTOOLS.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing.Color;
using Leadtools.Dicom;
using Leadtools.Drawing;
using Leadtools.Controls;
using Leadtools.Svg;
public void GetRowColumnExample()
{
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1.CMP"));
// This example does not work with rotated view perspectives.
if ((image.ViewPerspective != RasterViewPerspective.TopLeft) || (image.ViewPerspective != RasterViewPerspective.BottomLeft))
image.ChangeViewPerspective(RasterViewPerspective.TopLeft);
// Specify a rectangle in the top left part of the displayed image.
int xOffset = Convert.ToInt32(image.Width / 8); // Column offset of the rectangle to process.
int xSize = Convert.ToInt32(image.Width / 3); // Pixel width of the rectangle to process.
int yOffset = Convert.ToInt32(image.Height / 8); // Row offset of the rectangle to process.
int ySize = Convert.ToInt32(image.Height / 3); // Pixel height of the rectangle to process.
// Adjust the YOffset if the view perspective is bottom left.
if (image.ViewPerspective == RasterViewPerspective.BottomLeft)
yOffset = image.Height - yOffset - ySize;
// Allocate the buffer.
byte[] Buffer = new byte[xSize * 3];
// Invert the colors of pixels in the rectangle.
image.Access();
for (int i = yOffset; i < yOffset + ySize; i++)
{
image.GetRowColumn(i, xOffset, Buffer, 0, xSize * 3);
for (int col = 0; col < xSize * 3; col++)
Buffer[col] ^= 0xFF;
image.SetRowColumn(i, xOffset, Buffer, 0, xSize * 3);
}
image.Release();
codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "IMAGE1_getrowcol.BMP"), RasterImageFormat.Bmp, 0);
image.Dispose();
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images";
}
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.junit.*;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
import static org.junit.Assert.*;
import leadtools.*;
import leadtools.codecs.*;
import leadtools.imageprocessing.core.*;
import leadtools.svg.*;
import leadtools.imageprocessing.CloneCommand;
import leadtools.imageprocessing.FillCommand;
import leadtools.imageprocessing.FlipCommand;
import leadtools.imageprocessing.GrayscaleCommand;
import leadtools.imageprocessing.color.InvertCommand;
import leadtools.imageprocessing.color.PosterizeCommand;
public void getRowColumnExample() {
final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";
RasterCodecs codecs = new RasterCodecs();
RasterImage image = codecs.load(combine(LEAD_VARS_IMAGES_DIR, "IMAGE1.CMP"));
String destFileName = combine(LEAD_VARS_IMAGES_DIR, "Image1_getRowCol.BMP");
// This example does not work with rotated view perspectives.
if ((image.getViewPerspective() != RasterViewPerspective.TOP_LEFT)
|| (image.getViewPerspective() != RasterViewPerspective.BOTTOM_LEFT))
image.changeViewPerspective(RasterViewPerspective.TOP_LEFT);
// Specify a rectangle in the top left part of the displayed image.
int xOffset = (int) (image.getWidth() / 8); // Column offset of the rectangle to process.
int xSize = (int) (image.getWidth() / 3); // Pixel width of the rectangle to process.
int yOffset = (int) (image.getHeight() / 8); // Row offset of the rectangle to process.
int ySize = (int) (image.getHeight() / 3); // Pixel height of the rectangle to process.
// Adjust the YOffset if the view perspective is bottom left.
if (image.getViewPerspective() == RasterViewPerspective.BOTTOM_LEFT)
yOffset = image.getHeight() - yOffset - ySize;
// Allocate the buffer.
byte[] Buffer = new byte[xSize * 3];
// Invert the colors of pixels in the rectangle.
image.access();
for (int i = yOffset; i < yOffset + ySize; i++) {
image.getRowColumn(i, xOffset, Buffer, 0, xSize * 3);
for (int col = 0; col < xSize * 3; col++)
Buffer[col] ^= 0xFF;
image.setRowColumn(i, xOffset, Buffer, 0, xSize * 3);
}
image.release();
// Save it
codecs.save(image, destFileName, RasterImageFormat.BMP, 0);
// Clean up
image.dispose();
codecs.dispose();
assertTrue("file unsuccessfully saved to " + destFileName, (new File(destFileName)).exists());
System.out.printf("File saved successfully to %s%n", destFileName);
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document